package com.jerei.crm.service.impl;

import com.jerei.crm.entity.FollowCustomer;
import com.jerei.crm.mapper.FollowCustomerMapper;
import com.jerei.crm.service.IFollowCustomer;
import com.jerei.crm.service.ex.InsertException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class FollowServiceImpl implements IFollowCustomer {

    @Autowired
    FollowCustomerMapper followCustomerMapper;

    @Override
    public void addFollow(String content,Integer cid,Integer uid) {

        FollowCustomer followCustomer=new FollowCustomer();
        Date time=new Date();
        followCustomer.setContent(content);
        followCustomer.setTime(time);
        followCustomer.setCid(cid);
        followCustomer.setUid(uid);
        Integer rows= followCustomerMapper.insertFL(followCustomer);
        if(rows!=1){
            throw new InsertException("添加跟踪记录失败");
        }

    }

    @Override
    public List<FollowCustomer> findByCid(Integer cid) {

        List<FollowCustomer> list=followCustomerMapper.findByCid(cid);

        return list;

    }
}
